package com.fingard.dsp.tcpserver;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;

public class BankQueue {

	private BlockingQueue<RequestNIO> queueReq = null;
	public BankQueue(ReqRespHeader p_bankHeader){
		queueReq = new LinkedBlockingQueue<RequestNIO>();
		bankHeader = p_bankHeader;
		isBlocked = false;
	}
	
	/**是否阻塞，当有新增时，解除阻塞*/
	public volatile boolean isBlocked;//
	
	public int countReq(){
		return queueReq.size();
	}
	
	public ReqRespHeader bankHeader;
	public boolean addReq(RequestNIO p_req) throws InterruptedException{
		queueReq.put(p_req);
		isBlocked=false;//当有新增时，解除阻塞
		return true;
	}
	
	public RequestNIO getReq() throws InterruptedException{
		return queueReq.take();
	}
}
